<?php /*a:4:{s:66:"D:\laragon\www\jiaqueshop\application\manage\view\members_add.html";i:1585363070;s:59:"D:\laragon\www\jiaqueshop\application\manage\view\base.html";i:1596192950;s:68:"D:\laragon\www\jiaqueshop\application\manage\view\public_upload.html";i:1591401853;s:68:"D:\laragon\www\jiaqueshop\application\manage\view\public_editor.html";i:1540951044;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
	<meta name="renderer" content="webkit">
<title>后台管理系统</title>
<link rel="stylesheet" href="/static/public/awesome/css/font-awesome.min.css" />

<link rel="stylesheet" href="/static/public/layui/css/layui.css" />

<link rel="stylesheet" href="/static/public/kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="/static/manage/css/style.css" />

	<link rel="stylesheet" href="/static/public/dist/zoomify.min.css">
	
<script src="/static/public/kindeditor/kindeditor-all.js"></script>
<script src="/static/public/kindeditor/lang/zh_CN.js"></script>
<script src="/static/public/ueditor/ueditor.config.js?t=<?php echo time();?>"></script>
<script src="/static/public/ueditor/ueditor.all.min.js"></script>
<script src="/static/public/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<body>
<?php if($is_auth): ?>

<script src="/static/public/My97DatePicker/WdatePicker.js"></script>
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="<?php echo url('index/welcome'); ?>"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>系统</span>
            <span class="icon-angle-right"></span>
            <span>会员管理</span>
            <span class="icon-angle-right"></span>
            <span><?php echo !empty($info) ? '编辑'  :  '添加'; ?>会员</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <div class="m-form">
                <form class="layui-form" id="j_form">
                    <table class="m-table">
                        <thead>
                            <tr>
                                <th colspan="2"><?php echo !empty($info) ? '编辑'  :  '添加'; ?>会员</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td width="15%"><label for="username">昵称</label></td>
                                <td><?php echo htmlentities($info['nickname']); ?></td>
                            </tr>
                            <tr>
                                <td width="15%"><label for="username">头像</label></td>
                                <td><img src="<?php echo htmlentities($info['headimgurl']); ?>" alt="" style="display: block; width: 50px; height: 50px;" /></td>
                            </tr>
                            <tr>
                                <td><label for="">请选择所属角色<em>*</em></label></td>
                                <td>
                                    <div class="lay-select">
                                        <select name="role_id" lay-filter="role_id">
                                            <?php if(is_array($roles) || $roles instanceof \think\Collection || $roles instanceof \think\Paginator): if( count($roles)==0 ) : echo "" ;else: foreach($roles as $key=>$role): ?>
                                            <option value="<?php echo htmlentities($role['id']); ?>"<?php if($info['role_id'] == $role['id']): ?> selected<?php endif; ?>><?php echo htmlentities($role['name']); ?></option>
                                            <?php endforeach; endif; else: echo "" ;endif; ?>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td><label for="">请选择分销等级<em>*</em></label></td>
                                <td>
                                    <div class="lay-select">
                                        <select name="level" lay-filter="level">
                                            <option value="0"<?php if($info['level'] == 0): ?> selected<?php endif; ?>>游客</option>
                                            <option value="1"<?php if($info['level'] == 1): ?> selected<?php endif; ?>>熊宝</option>
                                            <option value="2"<?php if($info['level'] == 2): ?> selected<?php endif; ?>>小熊</option>
                                            <option value="3"<?php if($info['level'] == 3): ?> selected<?php endif; ?>>大熊</option>
                                            <option value="4"<?php if($info['level'] == 4): ?> selected<?php endif; ?>>熊王</option>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <?php if($info): ?>
                            <tr id="j_member_points"<?php if($info['role_id'] == 2): ?> class="dn"<?php endif; ?>>
                                <td><label for="points">积分</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="points" id="points" placeholder="请输入用户积分" readonly value="<?php echo htmlentities($info['points']); ?>" /><span><a style="display: none" class="u-edit" data-id="<?php echo htmlentities($info['id']); ?>" data-key="points">修改</a></span></td>
                            </tr>
                            <tr id="j_member_balance">
                            <td><label for="balance">余额</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="balance" id="balance" placeholder="请输入用户余额" readonly value="<?php echo htmlentities($info['balance']); ?>" /><span></td>
                            </tr>
                            <tr id="j_member_voucher"<?php if($info['role_id'] != 2): ?> class="dn"<?php endif; ?>>
                                <td><label for="vouchers">抵用券</label></td>
                                <td><input type="text" class="u-ipt u-ipt-small" name="vouchers" id="vouchers" placeholder="请输入股东抵用券" readonly value="<?php echo htmlentities($info['vouchers']); ?>" /><span><a class="u-edit" data-id="<?php echo htmlentities($info['id']); ?>" data-key="vouchers">修改</a></span></td>
                            </tr>
                            <?php endif; ?>
                            <tr style="display: none">
                                <td><label for="">会员审核状态</label></td>
                                <td><div class="lay-checked"><input type="checkbox" name="checked" value="1" title="审核通过" lay-skin="primary"<?php echo !empty($info['checked']) ? ' checked'  :  ''; ?> /></div></td>
                            </tr>
                            <tr>
                                <td><label for="">会员启用状态</label></td>
                                <td>
                                    <input type="radio" name="status" value="1" title="启用"<?php if(!$info || $info['status'] == 1): ?> checked<?php endif; ?> />
                                    <input type="radio" name="status" value="0" title="禁用"<?php if($info && $info['status'] == 0): ?> checked<?php endif; ?> />
                                </td>
                            </tr>
                        </tbody>
                        <thead style="display: none">
                            <tr>
                                <th colspan="2">其他信息</th>
                            </tr>
                        </thead>
                        <tbody id="j_member_others">
                            
                        </tbody>
                    </table>
                    <div class="m-form-btn"><input type="hidden" name="id" value="<?php echo htmlentities($info['id']); ?>"><button id="j_btn" class="u-btn">确定提交</button></div>
                </form>
            </div>
        </div>
    </div>
</div>

<?php endif; ?>
<input type="hidden" name="action_uri" value="<?php echo url('action'); ?>" />

<input type="hidden" name="redirect_uri" value="<?php echo url('index'); ?>" />

<input type="hidden" name="region_uri" value="/manage/regions/regions" />
<script src="/static/public/js/jquery-1.10.2.js"></script>
<script src="/static/public/js/maniac.ui.js"></script>
<script src="/static/public/layui/layui.js" charset="utf-8"></script>
<script src="/static/public/js/aes.js"></script>
<script src="/static/public/js/mode-ecb-min.js"></script>
<script src="/static/public/js/utils.js"></script>
<script src="/static/public/js/dialog.js"></script>
<script src="/static/manage/js/form.js"></script>
<script src="/static/manage/js/js.js"></script>
<script src="/static/public/js/app.js"></script>
<script src="/static/public/js/encrypt.js"></script>
<script src="/static/public/dist/zoomify.min.js"></script>
<script type="text/javascript">
    $('.fdzoom').zoomify();
</script>

<script>
var aesKey = '<?php echo htmlentities($encrypt_key); ?>';
    $(function(){
        layui.use('layer', function(){
            var user_exists = parseInt('<?php echo !empty($user_exists) ? 1  :  0; ?>');
            var user_forbidden = parseInt('<?php echo !empty($user_forbidden) ? 1  :  0; ?>');
            var quit_force = parseInt('<?php echo !empty($quit_force) ? 1  :  0; ?>');
            var is_auth    = parseInt('<?php echo !empty($is_auth) ? 1  :  0; ?>');
            
            if (user_exists) {
                dialog.error('您所登录的用户已被删除', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (user_forbidden) {
                dialog.error('您的账户已被禁用', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }

            if (quit_force) {
                dialog.error('同一账户同一时间只能一人在线', function(){
                	top.location.href = '/manage';
                    return false;
                });
            }
            
            if (!is_auth) {
                dialog.error('您没有权限执行此操作', function(){
                    window.location.href = history.go(-1);
                    return false;
                });
            }
        });
    })
</script>

<script src="/static/public/js/jquery-ui.min.js"></script>
<script>

    /**

     * 上传图片

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     * @param  {boolean} multiple 是否允许多图上传

     */

    function upload_pic(uploader, ele, multiple)

    {

        var signature = setSign();

        uploader.render({

            elem: ele,

            field: 'imgFile',

            multiple: multiple,

            url: '<?php echo url("/manage/upload/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',

            headers: {signature: signature},

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    if (multiple) {

                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><input type="hidden" name="' + name + '[desc][]" value="' + ret.data.id + '" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {

                        // 上传单图

                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');

                    }

                    layer.close(index);

                } else {

                    dialog.error(ret.message);

                    layer.close(index);
                }
            }
        })
    }


    /**
     * 上传图片
     * @param  {object}  uploader upload 对象
     * @param  {string}  ele      容器选择器
     * @param  {boolean} multiple 是否允许多图上传
     */
    function sxupload_pic(uploader, ele, multiple)
    {
        var signature = setSign();
        uploader.render({
            elem: ele,
            field: 'imgFile',
            multiple: multiple,
            url: '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "type" => "image", "module" => request()->module() ?: "addons"]); ?>',
            headers: {signature: signature},
            done: function(ret){
                var index = dialog.loading();
                if (ret.status == 0) {
                    var name = $(this.item).attr('data-name');
                    // 上传完毕回调
                    if (multiple) {
                        // 上传多图
                        $(this.item).parent().find('.m-pics ul').append('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');
                    } else {
                        // 上传单图
                        $(this.item).parent().find('.m-pic ul').html('<li><img src="' + ret.data.attach_uri + '" alt="" /><a class="u-item"><i class="icon icon-remove"></i></a><input type="hidden" name="' + name + '" value="' + ret.data.id + '" /></li>');
                    }
                    layer.close(index);
                } else {
                    dialog.error(ret.message);

                    layer.close(index);
                }

            }

        })

    }



    /**

     * 上传附件

     * @param  {object}  uploader upload 对象

     * @param  {string}  ele      容器选择器

     */

    function upload_file(uploader, ele)

    {

        uploader.render({

            elem: ele,

            field: 'imgFile',

            accept: 'file',

            url: '<?php echo url("manage/upload/filemanager", ["path" => session("userid", "", session_prefix()), "type" => "file", "module" => request()->module() ?: "addons"]); ?>',

            done: function(ret){

                var index = dialog.loading();

                if (ret.status == 0) {

                    var name = $(this.item).attr('data-name');

                    // 上传完毕回调

                    $(this.item).parent().find('.m-files ul').append('<li><i class="icon-paper-clip"></i><input type="text" name="'+name+'[name][]" value="' + ret.data.title + '" /><a data-md5-file="' + ret.data.md5_file + '" data-id="' + ret.data.id + '" class="u-download">下载</a><a class="u-item" data-id="' + ret.data.id + '">删除</a><input type="hidden" name="' + name + '[value][]" value="' + ret.data.id + '" /></li>');

                    $(this.item).parent().find('.m-files').show();

                    layer.close(index);

                } else {

                	

                    dialog.error(ret.message);



                    layer.close(index);

                }

            }

        })

    }



    layui.use(['upload'], function(ele, multiple){

        // 得到 upload 对象

        var upload = layui.upload;

        // 上传单图

        upload_pic(upload, '.u-upload-pic', false);

        // 上传多图

        upload_pic(upload, '.u-upload-pics', true);

        // 上传附件

        upload_file(upload, '.u-upload-file');

        //双喜
        sxupload_pic(upload, '.sxu-upload-pic', false);
        sxupload_pic(upload, '.sxu-upload-pics', true);
    });

</script>
<script>
    var uploadJson = '<?php echo url("api/v1/upload", ["path" => session("userid", "", session_prefix()), "module" => request()->module() ?: "addons"]); ?>';
    var fileManagerJson = '<?php echo url("api/v1/filemanager", ["sub_path" => session("userid", "", session_prefix()), "module" => request()->module() ?: "addons"]); ?>';
</script>
<script>
    layui.use(['layer', 'form', 'upload'], function(){
        var form   = layui.form;
        var upload = layui.upload;
        
        get_form_html(0);
        
        form.on('select(role_id)', function(data){
            get_form_html(data.value);
        });
        
        $('.u-edit').on('click', function(){
            var $input = $(this).parent().prev();
            var $that  = $(this);
            var key    = $that.attr('data-key');
            var id     = $that.attr('data-id');
            var title  = key == 'points' ? '修改积分' : '修改抵用券';
            
            layer.open({
                type: 1,
                title: title,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: '<div class="m-edit-form"><input type="text" class="u-ipt"><p>直接填写增加或减少的数值即可，增加直接填写数字，减少请填写负数</p><input type="button" class="u-btn" id="j_edit_points" data-id="'+id+'" data-key="'+key+'" value="提交" /></div>'
            });
        });
        
        $('body').on('click', '#j_edit_points', function(){
            var id    = $(this).attr('data-id');
            var key   = $(this).attr('data-key');
            var value = parseInt($(this).parent().find('.u-ipt').val());
            
            if (!value) {
                dialog.error('请输入正确的数值');
                return false;
            }
            $.post('<?php echo url("balanceChange"); ?>', {id: id, key: key, value: value}, function(ret){
                if (ret.status == 0) {
                    dialog.success('修改成功', function(){
                        $('#' + key).val(parseInt($('#' + key).val()) + value);
                        layer.closeAll();
                    })
                }
            }, 'json');
        });
        
        function get_form_html(role_id)
        {
            var index   = dialog.loading();
            var form_id = role_id ? role_id : '<?php echo htmlentities($role_id); ?>';
            var id      = '<?php echo !empty($info['id']) ? htmlentities($info['id']) : 0; ?>';
            
            if (role_id == 2) {
                $('#j_member_points').addClass('dn');
                $('#j_member_voucher').removeClass('dn');
            } else {
                $('#j_member_points').removeClass('dn');
                $('#j_member_voucher').addClass('dn');
            }
            
            $.post('/api/v1/form-member_data-' + form_id + '-' + id, {}, function(ret){
                layer.close(index);
                if (ret.status == 0) {
                    var html = '';
                    for (var i = 0; i < ret.data.html.length; i++) {
                        var data = ret.data.html[i];
                        if (data.type == 'editor') {
                            var name = data.name;
                            html += '<tr><td colspan="2">' + data.label + '</td></tr><tr><td colspan="2">' + data.value + '</td></tr>';
                            $.getScript('../../static/public/kindeditor/kindeditor-all.js', function() {
                                KindEditor.create('textarea[name="' + name + '"]', { allowFileManager: true, uploadJson: uploadJson, fileManagerJson: fileManagerJson, afterBlur: function(){ this.sync();}});
                            });
                        } else {
                            html += '<tr><td width="15%">' + data.label + '</td><td>' + data.value + '</td></tr>';
                        }
                    }
                    $('#j_member_others').html(html);
                    form.render();
                    upload_pic(upload, '.u-upload-pic', false);
                    upload_pic(upload, '.u-upload-pics', true);
                    upload_file(upload, '.u-upload-file');
                    $(".m-jquery-sorted").sortable({
                        placeholder: '.ui-placeholder'
                    });
                }
            }, 'json');
        }
    });
</script>

</body>
</html>